package com.fulihui.weixinsdk.request.group;

import com.alibaba.fastjson.JSON;
import com.fulihui.weixinsdk.http.HttpMethodEnum;
import com.fulihui.weixinsdk.request.WeixinRequest;
import com.fulihui.weixinsdk.result.group.GroupGetResult;
import com.google.gson.Gson;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.TreeMap;

/**
 * 查询所有分组
 * Created by LeeSon on 2017/3/30 0030.
 */
@Data
public class GroupGetRequest extends WeixinRequest<GroupGetResult> {
    private transient String access_token;

    @Override
    public Map<String, String> urlParam() {
        Map<String, String> param = new TreeMap<>();
        if (StringUtils.isNotBlank(access_token)) {
            param.put("access_token", access_token);
        }
        return param;
    }

    @Override
    protected void childParam() {

    }

    @Override
    public String service() {
        return "https://api.weixin.qq.com/cgi-bin/groups/get";
    }

    @Override
    public String urlEndStr() {
        return null;
    }

    @Override
    public GroupGetResult parseResult(String respStr) {
        return new Gson().fromJson(respStr, GroupGetResult.class);
    }

    @Override
    public HttpMethodEnum httpMethod() {
        return HttpMethodEnum.GET;
    }

    @Override
    public String requestData() {
        return JSON.toJSONString(this);
    }
}
